<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./css/login_styles.css">
	<script src="client_modules/jquery/dist/jquery.js"></script>
	<script src="client_modules/angular/angular.js"></script>
	<script src="client_modules/bootstrap/dist/js/bootstrap.js"></script>
	<script language="JavaScript" src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
	<link rel="stylesheet" href="http://static.runoob.com/assets/bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="http://static.runoob.com/assets/jquery/2.0.3/jquery.min.js"></script>
	<script src="http://static.runoob.com/assets/bootstrap/3.3.7/js/bootstrap.min.js"></script>

	<title>登录</title>

</head>
<body ng-app="MerchantLogin" ng-controller="MerchantController">

	<div class="htmleaf-container">
		<div class="wrapper">
			<div class="container">
				<h1 style="color: #ffffff">欢迎</h1>

				<form class="form" id="loginForm">
					<input required="required" type="text" ng-model="cu.account" placeholder="用户名">
					<input required="required" type="password" ng-model="cu.password" placeholder="密码">
					<button type="button" ng-click="login()"  class="btn btn-default btn-lg" data-toggle="modal" data-target="#myModal" style="color: #388a5a">登录</button>
					</br> <a href="merchantRegist.html" class="regist">注册</a>
				</form>



			</div>


		</div>
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
						</button>
						<h4 class="modal-title" id="myModalLabel" style="text-align: center">
							登录失败！
						</h4>
					</div>
					<div class="modal-body">
					<h4 ng-bind="result"></h4>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							关闭
						</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		<script>
			$(function () {
				$('#myModal').modal('hide')});
		</script>
	</div>


</body>



<script>
	angular.module("MerchantLogin",[])
			.controller("MerchantController",function($scope,$http){
				$scope.cu=null;
				$scope.result=null;
				$scope.login=function(){
					var req={
						method:"GET",
						url:"merchant?account="+$scope.cu.account+"&password="+$scope.cu.password
					};
					var reason=document.getElementById("reasonOfError");
					$http(req)
							.then(function(res){
								console.log(res.data);
								switch(res.data){
									case "error":$scope.result="失败原因：服务器出错";break;
									case "false":$scope.result="失败原因：用户名或密码错误";break;
									case "-2":$scope.result="失败原因：黑名单";break;
									case "-1":$scope.result="失败原因：审核不通过";break;
									case "0":$scope.result="失败原因:待审核";break;
									case "1":window.location.href = "dishManager.html";break;
									default:$scope.result="失败原因:不明";break;
								}
							});
				}
			});




</script>
</html>
